<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户信息</title>
    <style scoped>
        /* 全局样式 */
        body {
            font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f7fa;
            margin: 0;
            padding: 0;
            color: #333;
            line-height: 1.6;
        }

        /* 导航栏样式 */
        .navbar {
            background-color: #ffffff;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 12px 0;
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
        }

        .navbar-brand {
            font-size: 18px;
            font-weight: 600;
            color: #2c3e50;
            text-decoration: none;
            display: flex;
            align-items: center;
        }

        .navbar-brand i {
            margin-right: 8px;
            color: #2980b9;
        }

        .navbar-nav {
            display: flex;
            align-items: center;
        }

        .nav-link {
            color: #555;
            font-size: 14px;
            text-decoration: none;
            font-weight: 500;
            margin-left: 15px;
            transition: color 0.3s ease;
            padding: 5px 10px;
            border-radius: 4px;
        }

        .nav-link:hover {
            color: #2980b9;
            background-color: #f0f8ff;
        }

        .btn-group {
            display: flex;
            align-items: center;
            margin-left: 15px;
        }

        .btn-group .btn {
            margin-left: 8px;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            white-space: nowrap;
        }

        .btn-primary {
            background-color: #3498db;
            color: white;
            border: none;
        }

        .btn-primary:hover {
            background-color: #2980b9;
        }

        .btn-outline-primary {
            background-color: transparent;
            color: #3498db;
            border: 1px solid #3498db;
        }

        .btn-outline-primary:hover {
            background-color: #3498db;
            color: white;
        }

        .btn-success {
            background-color: #2ecc71;
            color: white;
            border: none;
        }

        .btn-success:hover {
            background-color: #27ae60;
        }

        .btn-warning {
            background-color: #f39c12;
            color: white;
            border: none;
        }

        .btn-warning:hover {
            background-color: #d35400;
        }

        .btn-info {
            background-color: #3498db;
            color: white;
            border: none;
        }

        .btn-info:hover {
            background-color: #2980b9;
        }

        .btn-danger {
            background-color: #e74c3c;
            color: white;
            border: none;
        }

        .btn-danger:hover {
            background-color: #c0392b;
        }

        .welcome-text {
            margin-left: 15px;
            font-size: 14px;
            color: #555;
        }

        /* 主容器样式 */
        .container {
            max-width: 1200px;
            margin: 30px auto;
            padding: 0 20px;
            display: flex;
            gap: 30px;
        }

        /* 左侧面板样式 */
        .left-panel {
            flex: 1;
            min-width: 300px;
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            padding: 25px;
            margin-right: 20px;
        }

        /* 右侧面板样式 */
        .right-panel {
            flex: 2;
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            padding: 25px;
        }

        /* 标题样式 */
        .panel-title {
            margin-top: 0;
            color: #2c3e50;
            font-size: 20px;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #e8f5e9;
        }

        /* 用户头像 */
        .avatar {
            width: 120px;
            height: 120px;
            border-radius: 50%;
            object-fit: cover;
            border: 3px solid #e0f2f1;
            margin-bottom: 15px;
            display: block;
            margin-left: auto;
            margin-right: auto;
            transition: transform 0.3s ease;
        }

        .avatar:hover {
            transform: scale(1.05);
        }

        /* 用户信息列表 */
        .info-list {
            list-style: none;
            padding-left: 0;
        }

        .info-list li {
            margin-bottom: 10px;
            color: #555;
            font-size: 14px;
        }

        .info-list strong {
            color: #2c3e50;
            font-weight: 600;
            display: inline-block;
            width: 80px;
        }

        /* 按钮样式 */
        .button-group {
            margin-top: 20px;
        }

        .btn {
            display: inline-block;
            padding: 8px 16px;
            background-color: #4CAF50;
            color: white;
            text-decoration: none;
            border-radius: 4px;
            font-size: 14px;
            transition: all 0.3s ease;
            border: none;
            cursor: pointer;
        }

        .btn:hover {
            background-color: #388e3c;
        }

        .btn-danger {
            background-color: #f44336;
        }

        .btn-danger:hover {
            background-color: #d32f2f;
        }

        /* 欢迎信息 */
        .welcome-section {
            margin-bottom: 30px;
        }

        .welcome-section h2 {
            color: #2c3e50;
            font-size: 22px;
            margin-bottom: 10px;
        }

        .welcome-section p {
            color: #666;
            font-size: 14px;
            margin-bottom: 20px;
        }

        /* 实验室列表 */
        .lab-list {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 20px;
        }

        .lab-card {
            background-color: #f9f9f9;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }

        .lab-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .lab-card h3 {
            margin-top: 0;
            font-size: 16px;
            color: #2c3e50;
            margin-bottom: 8px;
        }

        .lab-card p {
            color: #666;
            font-size: 14px;
            margin: 0;
        }

        /* 空实验室提示 */
        .empty-lab-message {
            text-align: center;
            padding: 40px 0;
            color: #777;
            font-size: 16px;
            grid-column: 1 / -1;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .container {
                flex-direction: column;
            }

            .left-panel {
                margin-right: 0;
                margin-bottom: 20px;
            }
        }
    </style>
</head>
<body>

<!-- 导航栏 -->
<nav class="navbar">
    <div class="navbar-container">
        <a class="navbar-brand" href="#">
            <i class="fas fa-flask"></i>
            实验室辅助管理系统
        </a>
        <div class="navbar-nav">
            <span sec:authorize="isAuthenticated()">
                <div class="btn-group">
                    <span class="welcome-text">欢迎, <span sec:authentication="name"></span>!</span>
                    <a href="/user/logout" class="btn btn-sm btn-outline-danger">退出</a>
                    <a href="/user/userInfo" class="btn btn-sm btn-outline-secondary">个人中心</a>
                    <a href="/laboratory/Info" class="btn btn-sm btn-outline-success active">实验室管理</a>
                    <a href="/user/admin" class="btn btn-sm btn-outline-warning">管理员界面</a>
                    <a href="/email" class="btn btn-sm btn-outline-info">邮箱</a>
                </div>
            </span>
        </div>
    </div>
</nav>

<!-- 主容器 -->
<div class="container">
    <!-- 左侧：用户信息 -->
    <div class="left-panel">
        <h3 class="panel-title">个人信息</h3>

        <ul class="info-list">
            <!-- 用户头像 -->
            <img th:src="${userInfo?.image} ?: '/images/default-avatar.png'" alt="头像" class="avatar"/>

            <!-- 用户名 -->
            <p><strong th:text="${userDetails?.username} ?: '未知用户'"></strong></p>

            <!-- 邮箱 -->
            <li><strong>邮箱:</strong> <span th:text="${userInfo?.email} ?: '待修改'"></span></li>

            <!-- 真实姓名 -->
            <li><strong>真实姓名:</strong> <span th:text="${userInfo?.realName} ?: '待修改'"></span></li>

            <!-- 手机号 -->
            <li><strong>手机号:</strong> <span th:text="${userInfo?.phoneNumber} ?: '待修改'"></span></li>

            <!-- 用户等级 -->
            <li><strong>用户等级:</strong> <span th:text="${userDetails?.authorities} ?: '普通用户'"></span></li>
        </ul>

        <div class="button-group">
            <a th:href="@{/user/update}" class="btn">修改信息</a>
        </div>
    </div>

    <!-- 右侧：实验室列表 -->
    <div class="right-panel">
        <div class="welcome-section">
            <h2>欢迎，<span th:text="${userDetails.username}">用户名</span></h2>
            <p>你管理的实验室如下：</p>
        </div>

        <!-- 实验室列表 -->
        <div class="lab-list">
            <div th:each="lab : ${labMap}" class="lab-card">
                <h3 th:text="${lab.value}">实验室名称</h3>
                <p th:text="'ID: ' + ${lab.key}">实验室 ID</p>
            </div>

            <!-- 没有实验室时提示 -->
            <div class="empty-lab-message" th:if="${labMap.isEmpty()}">
                暂无管理的实验室。
            </div>
        </div>
    </div>
</div>

</body>
</html>